package fn;

public class Global {

	public static int DEC_TOL = 5;
	public static int DEC_STR = 3;

	public static double tol(double n) {
		double b = Math.pow(10, DEC_TOL);
		return Math.round(n * b) / b;
	}

	public static String str(double n) {
		String[] s = (n + "").split("E");
		int dot = s[0].indexOf(".");
		if (s[0].length() - dot > DEC_STR)
			s[0] = s[0].substring(0, dot + DEC_STR);
		if (s[0].charAt(s[0].length() - 1) == '0' && s[0].length() > 1)
			s[0] = s[0].substring(0, s[0].length() - 2);
		if (s[0].charAt(s[0].length() - 1) == '.')
			s[0] = s[0].substring(0, s[0].length() - 1);
		if (s.length < 2)
			return s[0];
		s[1] = " \\cdot 10 ^ {" + s[1] + "}";
		return s[0] + s[1];
	}

	public static void main(String[] args) {
		System.out.println(str(1000000000));
		System.out.println(str(100000));
		System.out.println(str(1));
		System.out.println(str(0.1));
		System.out.println(str(0.000000001));
		System.out.println(str(0.0000000000000010000001));
	}
}
